package com.ht.psplan;

import java.io.File;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2007-1-4
 * Time: 15:40:13
 * To change this template use File | Settings | File Templates.
 */
public class XlsFileFilter extends javax.swing.filechooser.FileFilter {

    public boolean accept(File f) {
        if (f.isDirectory()) return true;

        String extension = getExtension(f);
        if (extension != null)
            return extension.equals("xls");
        return false;
    }

    public String getDescription() {
        return "xls";
    }

    public static String getExtension(File f) {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 && i < s.length() - 1) {
            ext = s.substring(i + 1).toLowerCase();
        }
        return ext;
    }

}
